class Category {
  final String? id;
  final String? pid;
  final List<Category>? children;
  final String? name;
  final String? description;
  final String? cover;
  final String? hotCover;

  Category({
    required this.id,
    required this.pid,
    required this.children,
    required this.name,
    required this.description,
    required this.cover,
    required this.hotCover,
  });

  factory Category.fromJson(Map<String, dynamic> json) {
    return Category(
      id: json['id'],
      pid: json['pid'],
      children: (json['children'] as List).map((item) => Category.fromJson(item)).toList(),
      name: json['name'],
      description: json['description'],
      cover: json['cover'],
      hotCover: json['hotCover'],
    );
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['pid'] = pid;
    data['children'] = children!.map((item) => item.toJson()).toList();
    data['name'] = name;
    data['description'] = description;
    data['cover'] = cover;
    data['hotCover'] = hotCover;
    return data;
  }
}


class RootCategory {

  final List<Category> children;


  RootCategory({

    required this.children,

  });

  factory RootCategory.fromJson(List<dynamic> json) {
   RootCategory r = RootCategory(

        children: (json.map((item) => Category.fromJson(item)).toList()));
    return r;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};

    data['children'] = children.map((item) => item.toJson()).toList();

    return data;
  }
}